package com.edu.spider.controller;

import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.edu.spider.DTO.FindLocalTrainInfoDTO;
import com.edu.spider.DTO.SearchCTripTrainDTO;
import com.edu.spider.enity.TrainInfo;
import com.edu.spider.service.CtripTrainService;
import com.edu.spider.service.LocalTrainService;

/** 
 * @author : ljl
 * @date 创建时间：2018年9月19日 下午2:42:41 
 * @version 1.0 
 * @parameter  
 * @since  
 * @return  
 */
@RestController
public class TrainController {

	@Autowired
	private CtripTrainService ctripTrainTicketService;
	
	@Autowired
	LocalTrainService localTrainService;
	
	/**
	 * Author:ljl
	 * Date:2018年9月19日下午5:46:18
	 * Title: regularlyCheckTicketInformation 
	 * Description:定时查询车票信息，并记录，默认查到出发日期后一天
	 * @param searchTrainDTO
	 * @throws ParseException 
	 */
	@PostMapping("/ctripTrain/find")
	public void regularlyCheckTicketInformation(@RequestBody SearchCTripTrainDTO searchTrainDTO) throws ParseException{
		ctripTrainTicketService.regularlyCheckTicketInformation(searchTrainDTO);
	}
	
	/**
	 * Author:ljl
	 * Date:2018年9月21日下午2:06:31
	 * Title: findTrainInfoByConditional 
	 * Description:查询本地数据库车辆信息
	 * @param findLocalTrainInfoDTO
	 * @return
	 * @throws UnsupportedEncodingException 
	 * @throws ParseException 
	 */
	@PostMapping(value="/localTrain/find")
	public List<TrainInfo> findTrainInfoByConditional(@RequestBody FindLocalTrainInfoDTO findLocalTrainInfoDTO){
		return localTrainService.findTrainInfoByConditional(findLocalTrainInfoDTO);
	}	
	
}
